﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Data.Linq;

namespace DomainModel.Entities
{
    // This is the Linq to SQL class for the PersonalReferences table.
    // This is the bottom layer of the DAL.
    [Table(Name = "PersonalReferences")]
    public class PersonalReference : IDataErrorInfo
    {
        [Column(Name = "referenceID", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
        public int ReferenceID { get; set; }

        [Column(Name = "applicationID")]
        public int ApplicationID { get; set; }

        [Column(Name = "name")]
        public string Name { get; set; }
        [Column(Name = "phone_number")]
        public string PhoneNumber { get; set; }
        [Column(Name = "employer")]
        public string Employer { get; set; }
        [Column(Name = "job_title")]
        public string JobTitle { get; set; }

        public string this[string fieldName]
        {
            get
            {
                if (((fieldName == "Name") && string.IsNullOrEmpty(Name)) ||
                    ((fieldName == "Name") && (Name.Length > 50)))
                    return "Name must not be empty or longer than 50 characters.";
                if (((fieldName == "PhoneNumber") && string.IsNullOrEmpty(PhoneNumber)) ||
                    ((fieldName == "PhoneNumber") && (PhoneNumber.Length > 10)))
                    return "Phone number address must not be empty or longer than 10 characters.";
                if (((fieldName == "Employer") && string.IsNullOrEmpty(Employer)) ||
                    ((fieldName == "Emplyoer") && (Employer.Length > 25)))
                    return "Employer must not be empty or longer than 25 characters.";
                if (((fieldName == "JobTitle") && string.IsNullOrEmpty(JobTitle)) ||
                    ((fieldName == "JobTitle") && (JobTitle.Length > 25)))
                    return "Job title must not be empty or longer than 25 characters.";

                return null;
            }
        }

        public string Error { get { return null; } }
    }
}